<%--
  Created by IntelliJ IDEA.
  User: shen
  Date: 2020/2/8
  Time: 9:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath%>">
    <title>新增判断题</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <link rel="stylesheet" type="text/css" href="js/easyui/themes/default/easyui.css">

    <script type="text/javascript" src="js/jquery-2.0.0.js"></script>
    <script type="text/javascript" src="js/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="js/easyui/easyui.dateformat.js"></script>

    <%@include file="../common_resource.jsp" %>
    <style type="text/css">
        .main_body{
            /*position: relative;
            top:190px;*/
            font-size: 14px;
        }
        .listDiv{
            font-size: 13px;
        }
    </style>
    <script type="text/javascript">

        $.getJSON('Kld/selectAllLev/0', function (res) {
            var qxid = $('#questCatagory');

            $.each(res, function (index,item) {
                console.log('%i - %o', index, item);
                qxid.append('<option value="' + item.levKldID +'">' + item.levKldCtgr + '</option>');
            })
        });

        // 加二级知识点下拉列表
        function changeLevKld(ele) {
            var  levKldID= ele.options[ele.selectedIndex].value;
            $.getJSON('Kld/selectAllSecByLevID/0',{levKldID:  levKldID},function (res) {
                var secKldIDFrom = $('#secKldIDFrom');
                secKldIDFrom.empty();
                $.each(res, function (index,item) {
                    console.log('%i - %o', index, item);
                    secKldIDFrom.append('<option value="' + item.secKldID +'">' + item.secKldCtgr + '</option>');
                })
            });
        }


    </script>
    <script>
        // 将选中的知识点添加到提交处
        function addSecTo(secKldIDFrom,secKldIDTo,msg) {

            var secKldIDFrom = $("#" + secKldIDFrom);
            console.log(secKldIDFrom);
            var secKldIDTo = $("#" + secKldIDTo);
            var fromValue = secKldIDFrom.val() == null ? "" : $.trim(secKldIDFrom.val());// 获取select选择的或者text的value
            if (fromValue == ""||fromValue=="请选择..") {
                alert(msg);
                return;
            }
            if(secKldIDTo.find("option[value='"+fromValue+"']")[0]){
                alert("不能重复添加！");
                return;
            }

            var	secKldCtgr = secKldIDFrom.find("option:selected").text();// 获取select选择的text
            var secKldID = secKldIDFrom.find("option:selected").val();// 获取select选择的code
            secKldIDTo.append('<option value="' + secKldID +'">' + secKldCtgr + '</option>');// 为select追加一个option(下拉项)
            secKldIDTo.get(0).selectedIndex = 0;// 设置select索引值为0的项选中

        }
        // 删除select的option
        function delSec(secKldIDTo, msg) {
            var select = $("#" + secKldIDTo);
            var toValue = select.val() == null ? "" : $.trim(select.val());
            if (toValue == "") {
                alert(msg);
            } else {
                select.find("option[value='" + select.val() + "']").remove();// 删除select中选择的option
            }

        }

    </script>
    <script >

        function to(){
            location.href="question/selectAllDQuestions/0";
        }

    </script>
</head>
<body class="main_body">
<div class="container container-1180" >
    <div class="col" style="margin-top: 10px;">
        <div class="panel panel-info" >
            <div class="panel-heading">
                <span ><i class="fa fa-user"></i></span> <label><font style="font-weight: bold;margin-left: 10px;font-size: 17px">新&nbsp;增&nbsp;判&nbsp;断&nbsp;题</font></label>
                <label style="float: right;">
                    <div class="button_bar">
                        <button class="btn btn-info btn-sm" onclick="to();">查询判断题</button>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </div>
                </label>
            </div>

            <div style="margin-top: 20px">
                <form id="judgeForm" action="question/insertDQuestion/2" method="post">
                    <input type="hidden" name="questionType" value="2"/>
                    <!-- 添加操作标识 -->
                    <input type="hidden" name="flag" value="1"/>
                    <div style="margin-left:200px;">
                        <div >
                            <div style="float:left;" >
                                <label style="margin-right: 50px"><font color="red"></b>*</font>&nbsp;难度(请单击选择):</label>
                                <select id="difficulty" name="difficulty"   style="width:120px;margin-left:123px;margin-top: -30px;" class="easyui-validatebox form-control"  required="true" >
                                    <option value="0.25">0.25</option>
                                    <option value="0.5">0.5</option>
                                    <option value="0.75">0.75</option>
                                </select>
                                <br/><br/>
                            </div>
                        </div>
                        <br/><br/>
                        <div style="float:left;margin-left: -250px">
                            <label style="margin-left: 10px"><font color="red"></br>*</font>&nbsp;一级知识点(请单击选择)</label>
                            <label id="questCtgrError" class="catagoryMsg"></label>

                            <label style="margin-left: 40px"><font color="red"></br>*</font>&nbsp;二级知识点(可多选)</label>
                            <label style="margin-left: 48px"><font color="red"></br>*</font>&nbsp;涉及的二级知识点(多选)</label></br>

                            <jsp:include page="selectKld.jsp"></jsp:include>
                            <br/>
                        </div>
                    </div>
                    <br/>
                    <br/>
                    <table style="margin-left:200px;margin-top: 25px;float: left" width="750px;" cellpadding="0" cellspacing="0">
                        <tr >
                            <br/>
                            <th width="400" ><font color="red"></br>*</font>&nbsp;内容</th>
                            <th align="left">正确答案</th>
                        </tr>
                        <tr >
                            <td><textarea name="question" cols="65" rows="3" class="form-control" placeholder="请输入判断题题干......" style="margin-top: -10px"></textarea></td>
                            <td>
                                <div style="float:left;margin-left: 5px;margin-top: -13px;">
                                    <label><input type="radio" name="dCorrect" value="T" class="form-control" /><span  class="glyphicon glyphicon-ok" ></span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <label>&nbsp;<input type="radio" name="dCorrect" value="F" class="form-control" /><span  class="glyphicon glyphicon-remove" ></span></label>
                                    <br/>
                                    <label id="tfMsg" class="catagoryMsg"></label>
                                </div>
                            </td>
                        </tr>
                        <tr style="height: 50px;">
                            <td colspan="2" style="padding-left:225px;">
                                <input type="submit" value="保存" class="btn btn-info"/>&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="reset" value="重置" class="btn btn-warning"/>
                            </td>
                        </tr>
                    </table>

                </form>
            </div>
        </div>
    </div>
</div>

<script src="bootstrap/js/bootstrap.min.js"></script>

<!-- 添加成功模态 -->
<div class="modal fade" id="insertSuccessModal" tabindex="-1" role="dialog"
     aria-labelledby="insertSuccessModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal1">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3>判断题添加成功</h3>
            </div>
            <div class="modal-footer">
                <button id="closeModal" type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 添加失败模态 -->
<div class="modal fade" id="insertFailModal" tabindex="-1" role="dialog"
     aria-labelledby="insertFailModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal2">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3>判断题添加失败</h3>
            </div>
            <div class="modal-footer">
                <button  type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>
<c:remove var="insertDQuestion" scope="session"/>


